﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;


public class GameOfSegments
{

    public int winner(int N)
    {
        int[] dp = new int[N];
        dp[3] = 1;
        dp[4] = 1;
        dp[5] = 2;

        if ( dp[N] != 0 ) return dp[N];

        for (int i = 2; i < N - 2; i++)
        {
            
        }
        return 0;
    }
}


public class BuildingHeightsEasy
{
    public int minimum(int M, int[] heights)
    {
        int[] sorted = heights.OrderBy(p => p).ToArray();

        if (M >= heights.Length) return 0;

        int min = -1;
        for ( int i = 0 ; i <= heights.Length - M ; i++ ) {
            int needed = 0;
            for ( int j = i ; j < i+M ; j++ ) {
                needed += sorted[i+M-1] - sorted[j];
            }
            if ( min == -1 || needed < min ) {
                min = needed;
            }
        }
        return min;

    }
}


public class CostOfDancing
{
    public int minimum(int K, int[] danceCost)
    {
        int[] sorted = danceCost.OrderBy(p => p).ToArray();

        int sum = 0;
        for (int i = 1; i <= K; i++)
        {
            sum += sorted[i-1];
        }
        return sum;
    }
}
